<?php
/**
 * 合同自定义表排序
 */

return array(
    array("field" => 'id', "title" => '合同ID', "sortable" => true),
    array("field" => 'number', "title" => '合同编号', "operate" => "LIKE", "align" => 'left',
        "formatter" => '(function (value, row, index) {
         return \'<a href="javascript:void(0);" data-url="facrm/contract/index/detail/ids/\' + row.id
             + \'" data-area="[&quot;100%&quot;,&quot;100%&quot;]" class="btn-dialog" data-title="\' + value + \'">\' + value + \'</a>\';
     })',),
    array("field" => 'name', "title" => '合同名称', "operate" => "LIKE", "align" => 'left',
        "formatter" => '(function (value, row, index) {
          //判断是否逾期
          var newtime = Math.round(new Date().getTime() / 1000).toString();
          if (newtime > row.end_time)
              value = \'<span class="label label-danger">过期</span>\' + value;
          return value;
      })',),
    array("field" => 'customer_id', "title" => '客户名称', "align" => 'left',
        "formatter" => '(function (value, row, index) {
                    if (!row.customer) return \'-\';
                    return \'<a href="javascript:void(0);" data-url="facrm/customer/index/detail/ids/\' + row.customer.id
                        + \'" data-area="[&quot;100%&quot;,&quot;100%&quot;]" class="btn-dialog" data-title="\' + row.customer.name + \'">\' + row.customer.name + \'(\' + row.customer_id + \')\' + \'</a>\';
                })',
        "addclass" => "selectpage", 'extend' => 'data-source="facrm/customer/index?filter=%7B\"scene_id\"%3A\"1\"%7D" data-field="name" data-orderBy="id desc"'),

    array("field" => 'money', "title" => '合同金额', "sortable" => true, 'operate' => 'BETWEEN'),
    array("field" => 'return_money', "title" => '回款金额', "sortable" => true, 'operate' => 'BETWEEN'),
	array("field" => 'order_time', "title" => '下单时间', "sortable" => true, 'operate' => 'RANGE', "formatter" => "Table.api.formatter.datetime",
    'datetimeFormat'=>"YYYY/MM/DD","extend"=>'autocomplete="off" data-time-picker="true"','addclass'=>'datetimerange'),
    array("field" => 'remark', "title" => '备注', "align" => "left", 'operate' => 'LIKE'),
    array("field" => 'start_time', "title" => '开始时间', "operate" => "RANGE", "sortable" => true, "formatter" => "Table.api.formatter.datetime", "addclass" => "datetimerange", "extend" => 'autocomplete="off" data-time-picker="true"'),
    array("field" => 'end_time', "title" => '结束时间', "operate" => "RANGE", "sortable" => true, "formatter" => "Table.api.formatter.datetime", "addclass" => "datetimerange", "extend" => 'autocomplete="off" data-time-picker="true"'),
    array("field" => 'create_user_id', "title" => '创建人', "addclass" => "selectpage", "formatter" => '(function (v, r) {
                    if (!r.create_user) return \'-\';
                    return r.create_user.nickname;
                })',
        "extend" => 'data-source="facrm/common/selectpage/model/admin?type=all" data-field="nickname" data-orderBy="id desc"',
    ),

    array("field" => 'order_admin_id', "title" => '签约人', "addclass" => "selectpage", "formatter" => '(function (v, r) {
                    if (!r.order_admin) return \'-\';
                    return r.order_admin.nickname;
                })',
        "extend" => 'data-source="facrm/common/selectpage/model/admin?type=all" data-field="nickname" data-orderBy="id desc"',
    ),

    array("field" => 'create_time', "title" => '创建时间', "operate" => "RANGE", "sortable" => true, "formatter" => "Table.api.formatter.datetime", "addclass" => "datetimerange", "extend" => 'autocomplete="off" data-time-picker="true"'),
    array("field" => 'check_status', "title" => '状态', "formatter" => "Table.api.formatter.status", "searchList" => 'check_status'),



);
